﻿//using dz.u9.jky.schema.Common;
//using System;
//using System.Collections.Generic;
//using System.Web.Http;
//using UFIDA.U9.Base.Doc;
//using UFIDA.U9.CBO.FI_SCM.DTOs;
//using UFIDA.U9.CBO.SCM.Customer;
//using UFIDA.U9.CBO.SCM.Enums;
//using UFIDA.U9.CBO.SCM.Item;
//using UFIDA.U9.ISV.RCV;
//using UFIDA.U9.ISV.RCV.DTO;
//using UFIDA.U9.PM.DTOs;
//using UFIDA.U9.PM.Enums;
//using UFSoft.UBF.Util.Log;

//namespace dz.inner.jky.api
//{
//    /// <summary>
//    /// 收货单
//    /// </summary>
//    public class DzReceivementController : DzBaseController
//    {

//        /// <summary>
//        /// 新增销售退货
//        /// </summary>
//        /// <returns></returns>
//        /// 
//        [HttpPost]
//        public U9CResult AddSaleReturn(dz.u9.jky.schema.PM.Receivement receivement)
//        {
//            U9CResult rtn = new U9CResult();

//            try
//            {
//                CreateRCVSRV svc = new CreateRCVSRV();

//                svc.RCVList = Convert(receivement);

//                UFIDA.U9.PM.Rcv.Receivement.EntityList receivements = svc.Do();

//                rtn.IsSuccess = true;
//                rtn.DocNo = receivements[0].DocNo;
//                rtn.Id = receivements[0].ID;

//            }
//            catch (Exception ex)
//            {
//                rtn.IsSuccess = false;
//                logger.Error(ex);
//                rtn.Message = ex.Message;
//            }

//            return rtn;
//        }
//        /// <summary>
//        /// test
//        /// </summary>
//        /// <param name="result"></param>
//        /// <returns></returns>
//        [HttpPost]
//        public U9CResult test(U9CResult result)
//        {
//            U9CResult rtn = new U9CResult();

//            try
//            {
//                OBAReceivementDTO aa = GetReceivement2();
//                CreateRCVSRV svc = new CreateRCVSRV();

//                OBAReceivementDTO dto1 = GetReceivement1();
//                //string s1 = InnerUtil.SerializeObject(dto1,false);

//                OBAReceivementDTO dto = GetReceivement2();
//                //string s2 = InnerUtil.SerializeObject(dto,false);
//                List<OBAReceivementDTO> dtos = new List<OBAReceivementDTO>();
//                dtos.Add(dto);

//                svc.RCVList = dtos;

//                UFIDA.U9.PM.Rcv.Receivement.EntityList receivements = svc.Do();

//                rtn.IsSuccess = true;
//                rtn.DocNo = receivements[0].DocNo;
//                rtn.Id = receivements[0].ID;

//            }
//            catch (Exception ex)
//            {
//                rtn.IsSuccess = false;
//                ILogger logger = LoggerManager.GetLogger("dz.inner.jky.api");
//                logger.Error("DzReceivementController.test", ex);
//                rtn.Message = ex.Message;                
//            }
            

            

//            return rtn;
//        }

//        private OBAReceivementDTO GetReceivement1()
//        {
//            OBAReceivementDTO dto = new OBAReceivementDTO();

//            #region 单头
//            dto.BusinessDate = DateTime.Now;
//            dto.SrcDocType = RcvSrcDocTypeEnum.CreateManual;
//            dto.AC = new BESimp4UIDTO() { Code = "C001" };
//            dto.RcvDocType = new BESimp4UIDTO() { Code = "RCV19" };
//            dto.BizType = BusinessTypeEnum.SD_StandardSale;
//            dto.RtnCustomer = new CustomerMISCInfo() { Code = "addtest01" };
//            dto.FC = dto.AC;
//            dto.TC = dto.AC;
//            dto.RejectMode = RejectModeEnum.Empty;
//            dto.ReceivementType = ReceivementTypeEnum.SaleReturn;

//            dto.RtnType = RtnTypeEnum.INVRTN;
//            dto.OrgCode = "100";
//            dto.ACToFCExRate = 1;
//            dto.RcvFees = new List<OBARcvFeeDTO>();
//            dto.RcvDiscount = new List<OBARcvDiscountDTO>();
//            dto.RcvTax = new List<OBARcvTaxDTO>() { };
//            dto.RcvAddress = new List<OBARcvAddressDTO>() { };
//            dto.RcvContacts = new List<OBARcvContactDTO>() { };
//            #endregion

//            #region 单体
//            OBARcvLineDTO line = new OBARcvLineDTO();

//            line.CustomerShipToSite = new CustomerSiteMISCInfo() { Code = "addtest01" };
//            line.PriceUOM =  new BESimp4UIDTO() { Code = "N006" };
//            line.TradeUOM = new BESimp4UIDTO() { Code = "N006" };
//            line.StoreUOM = new BESimp4UIDTO() { Code = "N006" };
//            line.ItemInfo = new ItemInfo() { ItemCode = "1101000201" };
//            line.DocLineNo = 1;
//            line.ArriveQtyTU = 1;
//            line.PlanQtyTU = 1;
//            line.TaxType = TaxMnyTypeEnum.Empty;
//            line.OrderPriceTC = 0;
//            line.FinallyPriceTC = 0;

//            line.SysPriceTC = 0;
//            line.FinallyPriceTC = 0;
//            line.ArrivedTime = DateTime.Now;
//            line.TotalMnyTC = 0;
//            line.TotalTaxTC = 0;
//            line.TotalNetMnyTC = 0;
//            CustomerSite.FindByCode("addtest01");
//            line.CustomerShipToSite = new CustomerSiteMISCInfo() { Code = "addtest01", CustomerSite = CustomerSite.FindByCode("addtest01") };
//            line.RcvDiscount = new List<OBARcvDiscountDTO>() { };
//            line.RcvTaxs = new List<OBARcvTaxDTO>() { };
//            line.RcvLineDispenses = new List<OBARcvLineDispenseDTO>() { };
//            line.RcvLineAllotMOs = new List<OBARcvLineAllotMODTO>() { };
//            line.RcvLineLocations = new List<OBARcvLineLocationDTO>() { };
//            line.RcvAddress = new List<OBARcvAddressDTO>() { };
//            line.RcvContacts = new List<OBARcvContactDTO>() { };
//            line.RcvSubLines = new List<OBARcvSubLineDTO>() { };
//            line.EvaluationPriceCU = 10;
//            line.EvaluationMnyAC = 10;
//            line.Wh = new BESimp4UIDTO() { Code = "01" };
//            line.ConfirmDate = DateTime.Now;



//            dto.RcvLines = new List<OBARcvLineDTO>() { line };

//            #endregion

//            return dto;
//        }

//        private OBAReceivementDTO GetReceivement2()
//        {
//            dz.u9.jky.schema.PM.Receivement rcv = new dz.u9.jky.schema.PM.Receivement();
//            #region 单头
//            rcv.BusinessDate = DateTime.Now;
//            rcv.SrcDocType = 0;
//            rcv.AC = "C001";
//            rcv.RcvDocType = "RCV19";
//            rcv.BizType = 449;
//            rcv.RtnCustomer = "addtest01";
//            rcv.FC = rcv.AC;
//            rcv.TC = rcv.AC;
//            rcv.RejectMode = -1;
//            rcv.ReceivementType = 2;
//            rcv.RtnType = 0;
//            rcv.OrgCode = "100";
//            #endregion

//            #region 单体
//            dz.u9.jky.schema.PM.RcvLine line = new dz.u9.jky.schema.PM.RcvLine();

//            line.CustomerShipToSite = "addtest01";
//            line.PriceUOM = "N006";
//            line.TradeUOM =  "N006" ;
//            line.StoreUOM =  "N006" ;
//            line.ItemInfo = "1101000201";
//            line.DocLineNo = 1;
//            line.ArriveQtyTU = 1;
//            line.PlanQtyTU = 1;
//            line.TaxType = -1;
//            line.OrderPriceTC = 0;
//            line.FinallyPriceTC = 0;

//            line.SysPriceTC = 0;
//            line.FinallyPriceTC = 0;
//            line.ArrivedTime = DateTime.Now;
//            line.TotalMnyTC = 0;
//            line.TotalTaxTC = 0;
//            line.TotalNetMnyTC = 0;            
//            line.CustomerShipToSite = "addtest01";
//            line.EvaluationPriceCU = 30;
//            line.EvaluationMnyAC = 30;
//            line.Wh = "01";
//            line.ConfirmDate = DateTime.Now;

//            rcv.RcvLines = new List<dz.u9.jky.schema.PM.RcvLine>() { line };

//            #endregion

//            //InnerUtil.SerializeObject(rcv, true);

//            OBAReceivementDTO dto = new OBAReceivementDTO();

//            dynamic c = (dynamic)dto;

//            ObjectCopyUtil util = new ObjectCopyUtil();
//            util.CopyProperty(rcv, ref c);

//            OBAReceivementDTO rtn = (OBAReceivementDTO)dto;


//            return rtn;
//        }

//        private List<OBAReceivementDTO> Convert(u9.jky.schema.PM.Receivement receivement)
//        {
//            OBAReceivementDTO dto = new OBAReceivementDTO();

//            ObjectCopyUtil util = new ObjectCopyUtil();
//            util.CopyProperty(receivement, ref dto);

//            List<OBAReceivementDTO> rtn = new List<OBAReceivementDTO>() { dto };

//            return rtn;
//        }


//    }
//}
